home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Atari Compendium
/
The Atari Compendium (Toad Computers) (1994).iso
/
files
/
umich
/
music
/
eked-m1.zoo
/
src
/
gm
/
form_man.c
next >
Wrap
C/C++ Source or Header
|
1995-02-19
|
5KB
|
173 lines
/*
* EKED-M1 : Editor for Korg M1 synth; form_man.c : form routines
* Copyright (C) 1995 Steven M. Eker (Steven.Eker@brunel.ac.uk)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stddef.h>
#include <stdio.h>
#include <osbind.h>
#include <gemfast.h>
#include <aesbind.h>
#include <string.h>
#include "gem_man.h"
int fm_dialog(OBJECT *tree, int ed, OBJECT *org_tree, int org_ob)
{
int but;
GRECT org;
GRECT pos;
if(org_tree){
objc_offset(org_tree, org_ob, &org.g_x, &org.g_y);
org.g_w = org_tree[org_ob].ob_width;
org.g_h = org_tree[org_ob].ob_height;
}
form_center(tree, &pos.g_x, &pos.g_y, &pos.g_w, &pos.g_h);
form_dial(FMD_START, 0, 0, 0, 0, pos.g_x, pos.g_y, pos.g_w, pos.g_h);
if(org_tree){
form_dial(FMD_GROW, org.g_x, org.g_y, org.g_w, org.g_h,
pos.g_x, pos.g_y, pos.g_w, pos.g_h);
}
objc_draw(tree, 0, MAX_DEPTH, pos.g_x, pos.g_y, pos.g_w, pos.g_h);
but = fm_form_do(tree, ed) & 0x7fff;
if(org_tree){
form_dial(FMD_SHRINK, org.g_x, org.g_y, org.g_w, org.g_h,
pos.g_x, pos.g_y, pos.g_w, pos.g_h);
}
form_dial(FMD_FINISH, 0, 0, 0, 0, pos.g_x, pos.g_y, pos.g_w, pos.g_h);
tree[but].ob_state &= ~SELECTED;
return but;
}
static OBJECT *f_tree;
static int f_ed;
static int f_button;
static GRECT f_pos;
void fm_begin_dialog(OBJECT *tree, int ed)
{
form_center(tree, &f_pos.g_x, &f_pos.g_y, &f_pos.g_w, &f_pos.g_h);
form_dial(FMD_START, 0, 0, 0, 0, f_pos.g_x, f_pos.g_y, f_pos.g_w, f_pos.g_h);
objc_draw(tree, 0, MAX_DEPTH, f_pos.g_x, f_pos.g_y, f_pos.g_w, f_pos.g_h);
f_tree = tree;
f_ed = ed;
}
int fm_run_dialog()
{
f_button = fm_form_do(f_tree, f_ed) & 0x7fff;
return f_button;
}
void fm_end_dialog()
{
form_dial(FMD_FINISH, 0, 0, 0, 0, f_pos.g_x, f_pos.g_y, f_pos.g_w, f_pos.g_h);
f_tree[f_button].ob_state &= ~SELECTED;
}
int fm_form_do(OBJECT *tree, int focus)
{
int m_x, m_y, m_state, k_state, k_ret, n_clks;
int r, t, next_ob, cursor = 0, ob;
wind_update(BEG_UPDATE);
wind_update(BEG_MCTRL);
if(focus != 0)
objc_edit(tree, focus, 0, 0, ED_INIT, &cursor);
for(;;){
r = evnt_multi(MU_BUTTON | MU_KEYBD,
2 + 256, 3, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
(int *) NULL, 0L,
&m_x, &m_y, &m_state,
&k_state, &k_ret, &n_clks);
if(r & MU_BUTTON){
ob = objc_find(tree, 0, MAX_DEPTH, m_x, m_y);
if(ob != -1){
t = form_button(tree, ob, n_clks, &next_ob);
if(t == 0)
break;
if(next_ob != 0 && next_ob != focus){
objc_edit(tree, focus, 0, cursor, ED_END, &cursor);
focus = next_ob;
objc_edit(tree, focus, 0, 0, ED_INIT, &cursor);
}
}
}
if(r & MU_KEYBD){
t = form_keybd(tree, focus, 0, k_ret, &next_ob, &k_ret);
if(t == 0)
break;
if(next_ob != 0 && next_ob != focus){
objc_edit(tree, focus, 0, cursor, ED_END, &cursor);
focus = next_ob;
objc_edit(tree, focus, 0, 0, ED_INIT, &cursor);
}
if(k_ret != 0)
objc_edit(tree, focus, k_ret, cursor, ED_CHAR, &cursor);
}
}
wind_update(END_MCTRL);
wind_update(END_UPDATE);
return next_ob;
}
char *fm_file_select(char *title, char *mask, char *filename)
{
static char path[200], file[13];
char *p;
int i, but;
p = strrchr(filename, '\\');
if(p != NULL){ /* assume full path supplied */
strcpy(path, filename);
strcpy(path + (p - filename) + 1, mask);
strcpy(file, p + 1);
}
else{ /* otherwise build path from current drive */
i = Dgetdrv();
path[0] = 'A' + i;
path[1] = ':';
Dgetpath(path + 2, i + 1);
strcat(path, "\\");
strcat(path, mask);
strcpy(file, filename);
}
i = (gl_ap_version >= 0x0140) ? fsel_exinput(path, file, &but, title) :
fsel_input(path, file, &but);
if(!i || !but)
return (char *) NULL;
strcpy(strrchr(path, '\\') + 1, file);
return path;
}
void fm_ob_redraw(OBJECT *tree, int ob, GRECT *area)
{
objc_draw(tree, gm_opaque(tree, ob), MAX_DEPTH, area->g_x, area->g_y,
area->g_w, area->g_h);
}
int fm_alert(int but, int n)
{
char *alert;
rm_gaddr(R_STRING, n, &alert);
return form_alert(but, alert);
}